﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ZarzadzanieKlientami.aspx.cs" Inherits="DentistOffice.ZarzadzanieKlientami" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server" >
<h2>Znajdz pacjenta po nazwisku</h2>
Wprowadź część nazwiska 
<asp:TextBox ID="SearchTextBox" runat="server" onclick="this.style.borderColor = '#25446A';" onfocus="this.select(); this.style.borderColor = '#25446A';" onblur="this.style.borderColor = '#999';" AutoPostBack="true"></asp:TextBox>
<asp:Button ID="SearchButton" runat="server" Text="Szukaj" CssClass="but"/>
<br />
<h2>Lista Klientów</h2>

    <asp:EntityDataSource ID="ListaKlientow" runat="server" 
        ConnectionString="name=DentistEntities" DefaultContainerName="DentistEntities"  
        EnableDelete="True" EnableFlattening="False" EnableUpdate="True" 
        EntitySetName="Patients" EntityTypeFilter="Patient" >
    </asp:EntityDataSource>
    <asp:QueryExtender ID="SearchQueryExtender" runat="server" TargetControlID="ListaKlientow">
    <asp:SearchExpression SearchType="StartsWith" DataFields="surname">
    <asp:ControlParameter ControlID="SearchTextBox" />
    </asp:SearchExpression>
    </asp:QueryExtender>
    <asp:GridView ID="PokazKlientow" runat="server" DataSourceID="ListaKlientow" 
        AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
        DataKeyNames="id" BackColor="White" BorderColor="#3366CC" 
        BorderStyle="None" BorderWidth="1px" CellPadding="4">
        <Columns >
            <asp:TemplateField ShowHeader="false" >
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Aktualizuj"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Anuluj" ForeColor="Red"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Edytuj"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Usuń" ForeColor="Red"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            
          <asp:TemplateField HeaderText="ID" SortExpression="ID">
                
                <ItemTemplate>
                    <asp:Label ID="Label9" runat="server" Text='<%# Eval("id") %>' Width="50"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>  

            <asp:TemplateField HeaderText="Imię" SortExpression="name">
                <EditItemTemplate>
                    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("name") %>' Width="100"></asp:TextBox>
                    <br />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                     ControlToValidate="NameTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                     ControlToValidate = "NameTextBox"
                     ErrorMessage="Zacznij wielką literą."
                     ForeColor = "Red"
                     ValidationExpression="[A-Z][a-z]*"
                     Display="Dynamic"></asp:RegularExpressionValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>' Width="100"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Nazwisko" SortExpression="surname">
                <EditItemTemplate>
                    <asp:TextBox  ID="SurnameTextBox" runat="server" Text='<%# Bind("surname") %>' Width="100"></asp:TextBox>
              <br />
              <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
                     ControlToValidate="SurnameTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                     ControlToValidate = "SurnameTextBox"
                     ErrorMessage="Zacznij wielką literą."
                     ForeColor = "Red"
                     ValidationExpression="[A-Z][a-z]*"
                     Display="Dynamic"></asp:RegularExpressionValidator> 
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("surname") %>' Width="100"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Telefon" SortExpression="phone">
                <EditItemTemplate>
                    <asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("phone") %>' Width="100"></asp:TextBox>
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                     ControlToValidate="PhoneTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                     ControlToValidate = "PhoneTextBox"
                     ErrorMessage="Podaj prawidłowy numer."
                     ForeColor = "Red"
                     ValidationExpression="[0-9]{9}"
                     Display="Dynamic"></asp:RegularExpressionValidator> 
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("phone") %>' Width="100"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="email" SortExpression="email">
                <EditItemTemplate>
                    <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("email") %>' Width="100"></asp:TextBox>
               <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                     ControlToValidate="EmailTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" 
                    ControlToValidate = "EmailTextBox"
                    ErrorMessage="Podaj prawidłowy email."
                    ForeColor = "Red"
                    ValidationExpression="^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$"
                    Display="Dynamic"></asp:RegularExpressionValidator> 
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("email") %>' Width="100"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Miasto" SortExpression="city">
            
                <EditItemTemplate>
                    <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("city") %>' Width="100"></asp:TextBox>
                    <br />
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
                     ControlToValidate="CityTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server" 
                     ControlToValidate = "CityTextBox"
                     ErrorMessage="Zacznij wielką literą."
                     ForeColor = "Red"
                     ValidationExpression="[A-Z][a-z]*"
                     Display="Dynamic"></asp:RegularExpressionValidator> 
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Eval("city") %>' Width="100"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Numer ID dentysty" SortExpression="idDentist">
                <EditItemTemplate>
                    <asp:TextBox ID="DentistIDTextBox" runat="server" Text='<%# Bind("idDentist") %>' Width="50"></asp:TextBox>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
                     ControlToValidate="DentistIDTextBox" 
                     ErrorMessage="Pole wymagane."
                     ForeColor="Red"
                     Display="Dynamic"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Eval("idDentist") %>' Width="50"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="#003399" />
        <HeaderStyle BackColor="#25446A" Font-Bold="True" ForeColor="#CCCCFF" />
        <PagerStyle BackColor="#CCCCCC" ForeColor="#003399" HorizontalAlign="Left" />
        <RowStyle BackColor="White" ForeColor="#003399" />
        <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <SortedAscendingCellStyle BackColor="#EDF6F6" />
        <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
        <SortedDescendingCellStyle BackColor="#D6DFDF" />
        <SortedDescendingHeaderStyle BackColor="#002876" />
    </asp:GridView>


</asp:Content>
